package com.entity;

import java.util.*;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * FirstCategory entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "first_category", catalog = "dangdang")
public class FirstCategory implements java.io.Serializable {
	private static final long serialVersionUID = 1L;
	// Fields

	private Integer id;
	private String name;
	private List<SecondCategory> secondCategories = new ArrayList<SecondCategory>(
			0);

	// Constructors

	/** default constructor */
	public FirstCategory() {
	}

	/** minimal constructor */
	public FirstCategory(String name) {
		this.name = name;
	}

	/** full constructor */
	public FirstCategory(String name, List<SecondCategory> secondCategories) {
		this.name = name;
		this.secondCategories = secondCategories;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 200)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "firstCategory")
	public List<SecondCategory> getSecondCategories() {
		return this.secondCategories;
	}

	public void setSecondCategories(List<SecondCategory> secondCategories) {
		this.secondCategories = secondCategories;
	}

}